/**
 * Created by dell on 2015/7/22.
 */

var suctionDes = function() {

    var calculateInit = function() {
        $.post(basePath + "suction/design/calculateInit",function() {});
    };

    var recover = function() {
        $.get(basePath + "suction/design/getrecover",function(data) {
            $("input").autoInject({
                data:data,
                mode:"id"
            });
            Metronic.unblockUI();
        }).done(calculateInit());
    };

    var saveValue = function() {
        $("input").on("blur",function() {
            var $this = $(this);
            validate.init($this);
            if (validate.isNotNumber($this.val())) {
                validate.invalid();
                return;
            } else {
                $.ajax({
                    url: basePath + "suction/design/saveValue",
                    type:"post",
                    dataType:"json",
                    data: $this.attr("id") + "=" + $this.val() + "&paramName=" + $this.attr("id") + "&paramValue=" + $this.val()
                });
                validate.valid();
            }

        });
    };

    return {
        init: function() {
            Metronic.blockUI({
                boxed:true,
                message:"数据计算中..."
            });
            saveValue();
            recover();
            $.post(basePath + "suction/design/getInit",function() {})
        }
    }

}();
